package com.echo.echovividlive.exception;

import com.echo.echovividlive.domain.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public Result handleException(Exception e) {
        if (e instanceof NullPointerException) {
            e.printStackTrace();
            return Result.error("提交数据异常");
        }
        log.error("全局异常捕获:{}", e.getMessage());
        e.printStackTrace();
        return Result.error("系统内部异常");
    }
}
